﻿//-----------------------------------------------------------------------
// <copyright file="Person.cs" company="WpfDevelopment.com">
//     Copyright WpfDevelopment.com. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace Hrmsystem.Domain
{
    using System;
    using System.ComponentModel.DataAnnotations;
using WpfDevelopment.MVVM;

    /// <summary>
    /// The Person model class
    /// </summary>
    public abstract class Person : ModelBase
    {
        /// <summary>
        /// The first name of the person
        /// </summary>
        private string firstName = string.Empty;

        /// <summary>
        /// Gets or sets the first name.
        /// </summary>
        /// <value>The first name.</value>
        [Required(AllowEmptyStrings = false, ErrorMessage = "The First Name is required")]
        [StringLength(50, ErrorMessage = "The First Name lenght can't be greater than 50 characters.")]
        [UIHint("TextBox")]
        public string FirstName 
        { 
            get 
            {
                return this.firstName;
            }

            set
            {
                this.firstName = value;
                this.NotifyPropertyChanged(() => this.FirstName);
            }
        }

        /// <summary>
        /// Gets or sets the last name.
        /// </summary>
        /// <value>The last name.</value>
        [Required(AllowEmptyStrings = false, ErrorMessage = "The Last Name is required")]
        [StringLength(50, ErrorMessage = "The Last Name lenght can't be greater than 50 characters.")]
        [UIHint("TextBox")]
        public string LastName { get; set; }

        /// <summary>
        /// Gets or sets the birth date.
        /// </summary>
        /// <value>The birth date.</value>
        public DateTime BirthDate { get; set; }

        /// <summary>
        /// Gets the age of the person.
        /// </summary>
        public int Age
        {
            get { return new DateTime(DateTime.Now.Subtract(this.BirthDate).Ticks).Year - 1; }
        }

        /// <summary>
        /// Gets or sets the skill.
        /// </summary>
        /// <value>The skill.</value>
        public Skill Skill
        {
            get;
            set;
        }
    }
}
